import instance from './instance.js'

// post请求
export function doPost(url, data, config) {
    return instance.post(url, data, config)
      .catch((err) => console.log("err=", err));
}

// put请求
export function doPut(url, data, config) {
    return instance.put(url, data, config)
      .catch((err) => console.log("err=", err));
}

// delete请求
export function doDelete(url, config) {
    return instance.delete(url, config)
      .catch((err) => console.log("err=", err));
}

//get请求
export function doGet(url, data, config){
    const p = new URLSearchParams();
    for (let key in data) {
      p.append(key, data[key]);
    }
    url += `?${p.toString()}`;
    return instance
    .get(url, config)
    .catch((err) => console.log("err=", err));
}
